package connection;

import java.util.Vector;

public class CommandRelay {
	private Vector commands;

	public CommandRelay() {
		commands = new Vector();
	}
	
	public synchronized void addCommand(int command) {
		commands.addElement(new Integer(command));
		notify();
	}
	
	public synchronized int getCommand() {
		while (commands.size() == 0) {
			try {
				wait();
			} 
			catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		int command = ((Integer)commands.firstElement()).intValue();
		commands.removeElementAt(0);
		return command;
	}
}
